Skip to content

Conversation

@ccoVeille
Copy link
Collaborator

@ccoVeille ccoVeille commented Nov 15, 2025

Summary

Avoid panic on go-spew errors

Changes

wrap the calls to go-spew into a call to didPanic

Motivation

go-spew can panic when trying to diff certain types of values, there are open issues about this on their GitHub repository.

go-spew is unfortunately unmaintained, we cannot expect a fix any time soon. Also, because of go-spew's design, there are multiple causes for a panic, and fixing all of them would be a huge undertaking.

We already return an empty diff when the types are not comparable, or when the values are not from types that can be easily diffed by go-spew.

Let's hide the panic by recovering from it, and returning an empty diff instead. This is not ideal, but at least it prevents the entire program from crashing. The expected/actual values will still be printed, just without the diff.

Related issues

Closes #480

Related to

go-spew can panic when trying to diff certain types of values, there are
open issues about this on their GitHub repository.

go-spew is unfortunately unmaintained, we cannot expect a fix any time
soon. Also, because of go-spew's design, there are multiple causes for
a panic, and fixing all of them would be a huge undertaking.

We already return an empty diff when the types are not comparable, or
when the values are not from types that can be easily diffed by go-spew.

Let's hide the panic by recovering from it, and returning an empty diff
instead. This is not ideal, but at least it prevents the entire program from
crashing. The expected/actual values will still be printed, just without
the diff.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Panic in assert/require.Equal when calling into go-spew

1 participant